<?php
/**
 * Created by PhpStorm.
 * User: xiatong
 * Date: 2018/10/22
 * Time: 下午3:13
 */

namespace app\common\model;


class orderVip extends BaseModel
{
    protected $name = 'order_vip';

    /**
     * 关联用户表
     * @return \think\model\relation\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo('User');
    }

    /**
     * vip订单支付状态
     * @param $value
     * @return array
     */
    public function getPayStatusAttr($value)
    {
        $status = [0 => '待付款', 1 => '已付款'];
        return ['text' => $status[$value], 'value' => $value];
    }

    /**
     * 生成订单号
     */
    protected function orderNo()
    {
        return date('Ymd') . substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
    }

}